﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cosmos.Common;
using System.Text;
using System.Configuration;
using CoastalClimbing.Code;

namespace CoastalClimbing
{
    public partial class SignUp : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //btnSubmit.Enabled = false;

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            StringBuilder body = new StringBuilder();
            body.AppendLine("Name: " + txtFirstName.Text + " " + txtLastName.Text + "<br />");
            body.AppendLine("Address: " + txtStreetAddress.Text + ", " + txtCity.Text + ", " + txtState.Text + " " + txtZipCode.Text + "<br />");
            body.AppendLine("Email Address: " + txtEmailAddress.Text + "<br />");
            body.AppendLine("Phone: " + txtPhone.Text + "<br />");
            body.AppendLine("Birthdate: " + txtBirthDate.Text + "<br />");
            body.AppendLine("Emergency contact: " + txtEmergencyContact.Text + " " + txtEmergencyContactPhone.Text + "<br />");

            List<string> toAddresses = new List<string>() { "kensie@coastalclimbing.com" };
            Email email = new Email("New Member Sign Up", body.ToString(), "donotreply@coastalclimbing.com", toAddresses, null, null, true, System.Net.Mail.MailPriority.High, null);
            email.Send();

            DAL.PreSaleCreate(txtFirstName.Text, txtLastName.Text, txtEmailAddress.Text, txtBirthDate.Text, txtStreetAddress.Text, txtCity.Text, txtState.Text, txtZipCode.Text, txtEmergencyContact.Text, txtEmergencyContactPhone.Text, txtPhone.Text);

            Response.Redirect("~/Thanks.aspx");
        }
    }
}